<?php
namespace Wap\Model;
use  Think\Model;

class LotteryRecordModel extends Model
{
	protected  $tableName = "lottery_record";


    /*
    *用户当前活动参与次数
    */
	public function customerRecordNum($lotteryId = 0, $openid='')
	{
         
		 // $items = D('Wap/lottery_item')->where(array('lottery_id'=>$lotteryId) )->field('id')->select();  未添加lottery_id自段
		 //$lotteryItems = implode(",", array_column($items,'id'));    array_column >= php5.5
		 // $lotteryItems = implode(",", array_map('array_shift',$items));  未添加lottery_id自段
		
		 $condition['openid'] = $openid;
		 // $condition['lottery_item_id'] = array('in', $lotteryItems.',0'); 未添加lottery_id自段
		 $condition['lottery_id']  =  $lotteryId;
		 return $this->where($condition)->count();
	}


    /*
    *当前奖项出奖次数
    */
	public function itemRecordNum($lottery_item_id)
	{
		return $this->where(array('lottery_item_id'=> $lottery_item_id))->count();
	}

	/*
    *当前奖项当日出奖次数
    */
	public function itemRecordNumPerDay($lottery_item_id)
	{
		// return $this->where(array('lottery_item_id'=> $lottery_item_id))->count();

	}

	
}
?>